<template>

  <div class="fixed">
    <div class="avatar">
      <div class="login" @click="login" v-if="loginswitch">
        <img src="../../assets/img/login-img.png" alt="" class="login-img">
        <span class="login-text" style="color:#fff">点击登录</span>
        <van-icon name="arrow" class="login-icon" />
      </div>
      <div v-else  class="login">
        <img src="../../assets/img/login-img.png" alt="" class="login-img">
        <span class="login-text" style="color:#fff">{{ userName }}</span>
        <van-icon name="arrow" class="login-icon" @click="show=true"/>
      </div>
      <div class="msg"  style="color:#fff">
        <div class="msg-son"><span>-</span><span>动态</span>
          <div class="msg-d"></div>
        </div>
        <div class="mgs-g msg-son"><span>-</span><span>关注</span>
          <div class="msg-d"></div>
        </div>
        <div class="msg-f msg-son"><span>-</span><span>粉丝</span></div>
      </div>
    </div>
    <div class="member">
      <img src="../../assets/img/member-img.png" alt="" class="member-img">
      <div class="member-text">
        <span class="member-big">成为大会员</span>
        <span class="member-small">了解更多权益</span>
      </div>
      <div class="member-right">
        <span>立即开通</span>
        <van-icon name="arrow" class="login-icon" />
      </div>
    </div>
  </div>
  <div class="body">
    <div class="blue">
      <div class="blue-son"><img src="../../assets/img/blue-download.png" alt=""><span>离线缓存</span></div>
      <div class="blue-son"><img src="../../assets/img/blue-history.png" alt=""><span>历史记录</span></div>
      <div class="blue-son"><img src="../../assets/img/blue-collect.png" alt=""><span>我的收藏</span></div>
      <div class="blue-son"><img src="../../assets/img/blue-look.png" alt=""><span>稍后收看</span></div>
    </div>
  </div>
  <van-dialog v-model:show="show" title="是否退出登录" show-cancel-button @confirm="confirm" @cancel="show=false">
  </van-dialog>
</template>
<style lang="less" scoped>
.fixed {
  padding: 0.3rem 0.2rem 0 0.2rem;
  background: linear-gradient(#fd0087 50%,#FFF 90%);
  padding-bottom: 0.2rem;

  .icon {
    display: flex;
    flex-direction: row-reverse;
    height: 0.8rem;
    i {
      padding: 0.14rem;
    }
  }

  .avatar {
    height: 2.8rem;

    .login {
      height: 1.4rem;
      display: flex;
      align-items: center;
      position: relative;
      padding: 0.2rem;

      .login-img {
        height: 1.2rem;
        width: 1.2rem;
        border-radius: 50%;
        background: #ccc;
        border: 2px solid #ccc;
      }

      .login-text {
        padding-left: 0.3rem;
        font-size: 0.5rem;
      }

      .login-icon {
        position: absolute;
        right: 0.1rem;
        color: #ccc;
        font-size: 0.3rem;
      }
    }

    .msg {
      height: 1rem;
      display: flex;
      font-size: 0.36rem;

      .msg-son {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
        position: relative;

        .msg-d {
          height: 0.5rem;
          position: absolute;
          border-right: 2px solid #ccc;
          right: 0;
        }
      }

    }
  }

  .member {
    height: 1rem;
    background: #f8d1e1;
    border-radius: 0.2rem;
    padding: 0.1rem;
    display: flex;
    align-items: center;
    position: relative;

    .member-img {
      height: 0.8rem;
      width: 0.8rem;
    }

    .member-text {
      margin-left: 0.2rem;
      color: #f71792;

      .member-big {
        display: flex;
        flex-direction: column;
        font-size: 0.4rem;
        font-family: 黑体;
      }

      .member-small {
        font-size: 0.3rem;
      }
    }

    .member-right {
      height: 100%;
      position: absolute;
      right: 0.1rem;
      bottom: 0.05rem;
      font-size: 0.3rem;
      display: flex;
      align-items: center;
      color: #f71792;
    }
  }
}

.loading {
  width: 50px;
  height: 72px;
  margin-top: 8px;
  border-radius: 4px
}

.body {
  padding: 0.3rem 0.2rem 0;
  height: 11rem;
  overflow: scroll;

  .blue {
    display: flex;
    height: 1.2rem;
    font-size: 0.3rem;
    align-items: center;

    .blue-son {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;

      img {
        width: 0.8rem;
        height: 0.8rem;
        margin-bottom: 0.2rem;
      }
    }
  }

  .pink {
    .pink-title {
      font-size: 0.4rem;
      padding: 0.5rem 0.1rem 0.1rem;
      font-weight: bold;
    }

    .pink-content1 {
      display: flex;
      height: 1.2rem;
      font-size: 0.3rem;
      align-items: center;
      padding: 0.3rem 0.1rem;

      .pink-son {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;

        img {
          width: 0.8rem;
          height: 0.8rem;
          margin-bottom: 0.2rem;
        }
      }
    }

    .pink-content {
      display: flex;
      height: 1.2rem;
      font-size: 0.3rem;
      align-items: center;
      padding: 0.3rem 0;

      .pink-son {
        margin-left: 0.5rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;

        img {
          width: 0.8rem;
          height: 0.8rem;
          margin-bottom: 0.2rem;
        }
      }
    }
  }

  .across {
    .across-title {
      font-size: 0.4rem;
      padding: 0.5rem 0.1rem 0.1rem;
      font-weight: bold;
    }

    .across-item {
      padding: 0.3rem 0.1rem 0.3rem 0.7rem;
      box-sizing: border-box;
      display: flex;
      align-items: center;
      position: relative;

      img {
        height: 0.8rem;
        width: 0.8rem;
      }

      span {
        margin-left: 0.5rem;
        ;
        font-size: 0.3rem;
      }

      .across-icon {
        position: absolute;
        right: 0;
        font-size: 0.3rem;
        color: #ccc;
      }
    }
  }
}
</style>

<script setup>
import { useRouter } from 'vue-router';
import{computed,ref} from 'vue'

const router  = useRouter()
let login = () =>{
  if(true){
    router.push('/login')
  }
}
let userName = computed(() =>{
  if(window.localStorage.getItem('name')?.length >0){
    return window.localStorage.getItem('name')
  }
  return null
})
const loginswitch = computed(() =>{
  if(window.localStorage.getItem('token')?.length >0){
    return false
  }
  else{
    return true
  }
})
const show = ref(false)

const confirm= () =>{
  window.localStorage.removeItem('name')
  window.localStorage.removeItem('token')
  location.reload()
}
</script>